<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" import="java.sql.*"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="ookweb.*"%>
<%request.setCharacterEncoding("UTF-8");%>
<%@ include file="/head.jsp" %> 

<%
String dbuser = application.getInitParameter("dbuser");
String dbpass = application.getInitParameter("dbpass");
String dburl  = application.getInitParameter("dburl");

Conn con =new Conn(dbuser,dbpass,dburl);

Data data=new Data(dbuser,dbpass,dburl);
String act=request.getParameter("reg");
String nuname=(String)session.getAttribute("ookweb_user_username");
String userid=(String)session.getAttribute("ookweb_user_userid");
if("".equals(nuname) || nuname==null){
 response.sendRedirect(basePath+"ookweb/login.jsp");
}

%>
     <%@ include file="/menu.jsp" %> 
     <div class="div8"></div>
     <table width="100%" border="0" cellpadding="0" cellspacing="0">
       <tr>
         <td align="center" valign="top">
           <table width="100%" height="627" border="0" cellpadding="0" cellspacing="0">
             <tr >
               <td align="left" valign="top" >
               <table width="100%" border="0">
                  <tr>
                    <td height="38" valign="top" style=" background:url(images/msg.gif) no-repeat"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="10%" height="26" align="center" style=" color:#333333; font-size:14px; font-weight:bold;">&nbsp;&nbsp;留言板</td>
                        <td width="57%">&nbsp;</td>
                        <td width="33%" align="right" class="hui12">首页-&gt;留言板</td>
                      </tr>
                    </table></td>
                  </tr>
                </table>
                <div style=" font-size:12px; color:#999999; border-bottom:1px dashed #CCCCCC">&nbsp;&nbsp;&nbsp;&nbsp;欢迎登录东方通网站</div><br>
                <table width="100%" border="0" cellpadding="8" align="right">
	      <tr>
             <td width="22%" height="181" align="center" valign="top" >
             <table width="120" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td style=" height:26px; color:#666666;  font-size:14px; line-height:26px; vertical-align:middle; border-bottom:1px solid #9C9C9C"><a href="userinfo.jsp" style="color:#cccccc;text-decoration:none; font-size:14px;">我的个人资料</a></td>
              </tr>
               <tr>
                <td  style=" height:26px; color:#666666;font-size:14px; font-weight:bold;line-height:26px;vertical-align:middle;border-bottom:1px solid #9C9C9C"><a href="msg.jsp" style="color:#cccccc; text-decoration:none;font-size:14px;">我的疑问解答</a></td>
              </tr>
              <tr>
                <td  style=" height:26px; color:#666666;font-size:14px; line-height:26px;vertical-align:middle;border-bottom:1px solid #9C9C9C"><a href="sub.jsp" style="color:#cccccc;text-decoration:none;font-size:14px;">我要提问</a></td>
              </tr>
            </table>           
             </td>
             <td width="78%" valign="top" class="infolist"><table width="542" border="0" cellpadding="0" cellspacing="0">
               <tr>
                 <td><img src="images/ucarea.gif" width="545" height="22" /></td>
               </tr>
               <tr align="center">
                 <td height="288" valign="top" background="images/ucbj.gif"><table width="96%" border="0" cellpadding="0" cellspacing="0">
                   <tr style=" border-bottom:1px solid #999999;">
                     <td width="23%" height="37" align="right" style=" border-bottom:1px solid #999999;"> <span class="STYLE3">我的疑问解答</span></td>
                     <td width="77%" style=" border-bottom:1px solid #999999;">&nbsp;</td>
                   </tr>
                   <tr>
                     <td colspan="2">&nbsp;</td>
                   </tr>
                   <tr>
                     <td colspan="2">  
                     <%
                     String msgid=request.getParameter("msgid");
                     if(!("".equals(msgid) || msgid==null)){ %>
                         <table width="90%" border="0" align="center" cellpadding="4" cellspacing="0">
                       <tbody>
                       <%
					                          //分页段 
					     //变量声明 
					String mysql=new String(); //SQL语句
					mysql=" web_msgreply where msgid="+msgid+" and userid="+userid;
					int intRowCount=0;  //总的记录数
					int intPageCount=0; //总的页数
					int intPageSize=15; //每页显示的记录数
					int intPage; //待显示页码 
					String strPage=new String(); //用来接收当页码参数
					int begin_no=0; //开始的rownum记录号
					int end_no=0;  //结束的rownum记录号
					
					//取得待显示页码 
					strPage = request.getParameter("page"); 
					if(strPage==null){//表明在QueryString中没有page这一个参数，此时显示第一页数据 
					intPage = 1; 
					} 
					else{//将字符串转换成整型 
					intPage = java.lang.Integer.parseInt(strPage); 
					if(intPage<1) intPage = 1; 
					} 
					//得到总的数据记录行数
					intRowCount=data.getRowCount(mysql); //总记录数
					
					//计算总共要分多少页
					intPageCount = (intRowCount+intPageSize-1) / intPageSize; 
					//调整待显示的页码 
					
					if(intPage>intPageCount) intPage = intPageCount; 
					//分页段
					
					begin_no=(intPage-1) * intPageSize + 1; 
        end_no = intPage * intPageSize;
	    mysql="select * from (select rownum row_id ,title,content,addtime from (select title,content,addtime from web_msgreply where msgid="+msgid+" and userid="+userid+" order by rmsgid desc))";
	    mysql=mysql+" where row_id between " +begin_no+ " and " +end_no;
	   //out.print(mysql);
	    ResultSet rs=con.getRs(mysql);
		int i=0;
		String title="";
		String siid="";
		while(rs.next()){
		i++;title=rs.getString("title");
		siid=rs.getString("msgid");
                        %>
                         <tr height="28">
                           <td width="20%" height="35" align="left" bgcolor="#FFFFFF" ><%=rs.getDate("addtime") %><br /></td>
                           <td width="80%" height="35" bgcolor="#FFFFFF"  align="left" ><strong><%=title %></strong></td>
                         </tr>
						  <tr height="28">
                           <td width="20%" height="35" align="left" bgcolor="#FFFFFF" style=" border-bottom:1px dashed #CCCCCC" ></td>
                            <td width="80%"  height="35" align="left" bgcolor="#FFFFFF" style=" border-bottom:1px dashed #CCCCCC"><%=rs.getString("content") %></td>
                         </tr>
                          <%} 
   if(intPageCount>1){
   %>
   <tr>
    <td colspan="2" align="center">
     第<%=intPage%>页 共<%=intPageCount%>页 
<a href="<%=basePath%>msg.jsp?page=1&msgid=<%=msgid%>"></a>
<%if(intPage>1){%><a href="<%=basePath%>msg.jsp?page=<%=intPage-1%>&msgid=<%=msgid%>">上一页</a><%}%> 
<%if(intPage<intPageCount){%><a href="<%=basePath%>msg.jsp?page=<%=intPage+1%>&msgid=<%=msgid%>">下一页</a><%}%> 
<a href="<%=basePath%>msg.jsp?page=<%=intPageCount%>&msgid=<%=msgid%>">尾页</a>
   </td>
   </tr>
   <%} con.close();%>
                       </tbody>
                     </table>
                     
                     
                     <% }else{
                      %>
                                                         
                     <table width="90%" border="0" align="center" cellpadding="4" cellspacing="0">
                       <tbody>
                       <%
					                          //分页段 
					     //变量声明 
					String mysql=new String(); //SQL语句
					mysql=" web_usermsg where userid="+userid;
					int intRowCount=0;  //总的记录数
					int intPageCount=0; //总的页数
					int intPageSize=15; //每页显示的记录数
					int intPage; //待显示页码 
					String strPage=new String(); //用来接收当页码参数
					int begin_no=0; //开始的rownum记录号
					int end_no=0;  //结束的rownum记录号
					
					//取得待显示页码 
					strPage = request.getParameter("page"); 
					if(strPage==null){//表明在QueryString中没有page这一个参数，此时显示第一页数据 
					intPage = 1; 
					} 
					else{//将字符串转换成整型 
					intPage = java.lang.Integer.parseInt(strPage); 
					if(intPage<1) intPage = 1; 
					} 
					//得到总的数据记录行数
					intRowCount=data.getRowCount(mysql); //总记录数
					
					//计算总共要分多少页
					intPageCount = (intRowCount+intPageSize-1) / intPageSize; 
					//调整待显示的页码 
					
					if(intPage>intPageCount) intPage = intPageCount; 
					//分页段
					
					begin_no=(intPage-1) * intPageSize + 1; 
        end_no = intPage * intPageSize;
	    mysql="select a.* from (select rownum row_id ,userid,msgid,title,content,addtime from (select msgid,userid,title,content,addtime from web_usermsg where userid="+userid+" order by msgid desc)) a";
	    mysql=mysql+" where row_id between " +begin_no+ " and " +end_no;
	   //out.print(mysql);
	    ResultSet rs=con.getRs(mysql);
		int i=0;
		String title="";
		String siid="";
		String content="";
		while(rs.next()){
		i++;title=rs.getString("title");
		siid=rs.getString("msgid");
		content=rs.getString("content");
                        %>
                         <tr height="28">
                           <td width="20%" height="35" align="left" bgcolor="#FFFFFF" ><strong></strong><%=rs.getDate("addtime") %><br /></td>
                           <td width="80%" height="35" bgcolor="#FFFFFF"  align="left" >
						   <strong><a href="msg.jsp?msgid=<%=rs.getString("msgid")%>"><%=title %></a></strong>
						   </td>
                         </tr>
						  <tr height="28">
                           <td width="20%"  height="35" align="left" bgcolor="#FFFFFF" style=" border-bottom:1px dashed #CCCCCC"></td>
                           <td width="80%"  height="35" align="left" bgcolor="#FFFFFF" style=" border-bottom:1px dashed #CCCCCC"><%=content %></td>
                         </tr>
                          <%} 
   if(intPageCount>1){
   %>
   <tr>
    <td colspan="2" align="center">
     第<%=intPage%>页 共<%=intPageCount%>页 
<a href="<%=basePath%>msg.jsp?page=1">首页</a>
<%if(intPage>1){%><a href="<%=basePath%>msg.jsp?page=<%=intPage-1%>">上一页</a><%}%> 
<%if(intPage<intPageCount){%><a href="<%=basePath%>msg.jsp?page=<%=intPage+1%>">下一页</a><%}%> 
<a href="<%=basePath%>msg.jsp?page=<%=intPageCount%>">尾页</a>
   </td>
   </tr>
   <%} con.close();%>
                       </tbody>
                     </table>
                 <%} %>
                     </td>
                   </tr>
                 </table></td>
               </tr>
               <tr>
                 <td><img src="images/ucareabot.gif" width="545" height="22" /></td>
               </tr>
             </table>
           
               </td>
	      </tr>
     </table>
			</td>
	      </tr>
     </table>
     		</td>
	      </tr>
     </table>
        <%@ include file="/right.jsp" %>

</div>